﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using KingRoad.EPM.PersonnelLogEntity.Model;
using Unis.Framework.Core.Utility;
using KingRoad.EPM.PersonnelLogDAL.PlmTurnoverService;


namespace KingRoad.EPM.PersonnelLogBLL.UIRules
{
    /// <summary> 
    /// 客户端业务处理类。 
    /// 文件生成时间 2017/2/16 18:40:48
    /// </summary> 
    public class PlmTurnoverUIRule
    {
        private readonly IPlmTurnoverService _plmTurnoverService;


        public PlmTurnoverUIRule() { }

        /// <summary> 
        /// construct function... 
        /// </summary> 
        public PlmTurnoverUIRule(IPlmTurnoverService plmTurnoverService)
        {
            _plmTurnoverService = plmTurnoverService;
        }


        /// <summary>
        /// 获取人员变动信息
        /// </summary>
        /// <returns></returns>
        public List<PlmTurnoverInfo> GetAllPlmTurnoverInfo()
        {
            var list = _plmTurnoverService.GetEntityList();
            return list;
        }
        /// <summary>
        /// 根据条件查询费用计划信息
        /// </summary>
        /// <param name="numCurrentPage">当前页</param>
        /// <param name="numPerPage">每页数据大小</param>
        /// <param name="orderByField">排序字段名称</param>
        /// <param name="totalRecord">总数据量</param>
        /// <param name="sqlCondition">sql查询条件</param>
        /// <returns></returns>
        public List<PlmTurnoverInfo> GetAllCostplanmainForPage(int numCurrentPage, int numPerPage,
                                                                        string orderByField, out int totalRecord, string sqlCondition)
        {
            var list = _plmTurnoverService.GetEntityListByContionRe(numCurrentPage, numPerPage, orderByField, out totalRecord, sqlCondition);
            return list;
        }
        /// <summary>
        /// 获取人员变动信息 根据ID获取
        /// </summary>
        /// <returns></returns>
        public PlmTurnoverInfo GetPlmTurnoverInfoByID(Guid id)
        {
            var list = _plmTurnoverService.GetEntityById(id);
            return list;
        }

        /// <summary>
        /// 添加人员变动信息
        /// </summary>
        /// <returns></returns>
        public int AddPlmTurnoverInfo(PlmTurnoverInfo AddEntity)
        {
            return _plmTurnoverService.InsertEntity(AddEntity);
        }

        /// <summary>
        /// 删除人员变动信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DeletePlmTurnoverInfo(string id)
        {
            return _plmTurnoverService.DeleteEntityByStringID(id);
        }

        /// <summary>
        /// 删除人员变动信息(批量删除)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DeletePlmTurnoverInfoMulti(string id)
        {
            return _plmTurnoverService.DeleteEntityByMultiStringID(id);
        }

        /// <summary>
        /// 更新人员变动信息
        /// </summary>
        /// <returns></returns>
        public int UpdatePlmTurnoverInfo(PlmTurnoverInfo UpdateEntity)
        {
            return _plmTurnoverService.UpdateEntity(UpdateEntity);
        }
        /// <summary>
        /// 判断是否存在AssisId
        /// </summary>
        /// <param name="assisId"></param>
        /// <returns></returns>
        public bool IsExitAssistId(int assisId)
        {
            var strSql = String.Format(" Assist_ID={0} ", assisId);
            var list = _plmTurnoverService.GetEntityList(strSql);
            return list.Any();
        }
    }
}